import { type FC, type HTMLAttributes } from 'react';
import CommonPanel, { type ICommonPanelView } from '.';
import DI from '../../utils/di';
import type TabService from '../../tabs/base/service';

abstract class BasePanelService extends DI implements ICommonPanelView {
  abstract tabs: TabService[];

  abstract title: string;

  component: FC<{ service: ICommonPanelView } & HTMLAttributes<HTMLDivElement>> = CommonPanel;

  init() {
    this._refreshKey = Math.random();

    this.tabs.forEach(it=>{
      it.bindBpmnService(this.root);
      it.bindPanelService(this.panel);
    });
    this.tabs.forEach(it=>{
      it.init();
    });
  }

  // 主要是为了fix valtio的渲染问题
  _refreshKey = Math.random();
}
export default BasePanelService;
